package com.example.demo.entity.es;

import java.util.Date;
import java.util.Map;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * @author 88377761
 * "from": "来源ID",
 * "to": "目标ID",
 * "cmd":"命令码(11)int类型",
 * "createTime": "消息创建时间long类型",
 * "msgType": "消息类型int类型(0:text、1:image、2:voice、3:vedio、4:music、5:news)",
 * "chatType":"聊天类型int类型(0:未知,1:公聊,2:私聊)",
 * "group_id":"群组id仅在chatType为(1)时需要,String类型",
 * "content": "内容",
 * "extras" : "扩展字段,JSON对象格式如：{'扩展字段名称':'扩展字段value'}"
 */
@Document(indexName = "msg", type = "docs", shards = 1, replicas = 0)
public class Msg {

	@Id
	private Long id;

	@Field(type = FieldType.Keyword)
	private String from; // 来源ID

	@Field(type = FieldType.Keyword)
	private String to;// 目标ID

	@Field(type = FieldType.Integer)
	private Integer cmd = 11; // 命令码(11)int类型

	@Field(type = FieldType.Long)
	private Long createTime; // 消息创建时间long类型

	@Field(type = FieldType.Integer)
	private Integer msgType = 0; // 消息类型int类型(0:text、1:image、2:voice、3:vedio、4:music、5:news)

	@Field(type = FieldType.Integer)
	private Integer chatType = 2; // 聊天类型int类型(0:未知,1:公聊,2:私聊)

	@Field(type = FieldType.Keyword)
	private String group_id;// 群组id仅在chatType为(1)时需要,String类型

	@Field(type = FieldType.Keyword)
	private String content;// 内容

	@Field(type = FieldType.Keyword)
	private Map<String, Object> extras;

	public Msg() {

	}

	public Msg(String from, String to, String content) {
		this.from = from;
		this.to = to;
		this.content = content;
		this.createTime = new Date().getTime();
	}
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

	public Integer getCmd() {
		return cmd;
	}

	public void setCmd(Integer cmd) {
		this.cmd = cmd;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public Integer getMsgType() {
		return msgType;
	}

	public void setMsgType(Integer msgType) {
		this.msgType = msgType;
	}

	public Integer getChatType() {
		return chatType;
	}

	public void setChatType(Integer chatType) {
		this.chatType = chatType;
	}

	public String getGroup_id() {
		return group_id;
	}

	public void setGroup_id(String group_id) {
		this.group_id = group_id;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Map<String, Object> getExtras() {
		return extras;
	}

	public void setExtras(Map<String, Object> extras) {
		this.extras = extras;
	}

}
